package com.array_list.phone;

import java.util.ArrayList;

public class Test_phone {
    public static void main(String[] args) {
        ArrayList<Phone> phones=new ArrayList<>();
        Phone phone1=new Phone("小米",1000);
        Phone phone2=new Phone("苹果",8000);
        Phone phone3=new Phone("锤子",2999);
        phones.add(phone1);
        phones.add(phone2);
        phones.add(phone3);
        for (int i = 0; i < split(phones).size(); i++) {
            System.out.println(split(phones).get(i).getBrand()+split(phones).get(i).getPrice());
        }
    }
    public static ArrayList<Phone> split(ArrayList<Phone> phones){
        ArrayList<Phone> list=new ArrayList<>();
        for (int i = 0; i < phones.size(); i++) {
            if (phones.get(i).getPrice()<3000){
                list.add(phones.get(i));
            }
        }
        return list;
    }
}
